<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试网页与原生通信</title>
    <style>
        .avatar {
            width: 300px;
            height: 300px;
            border-radius: 50%;
        }
    </style>
 
</head>
<body>
    <h1>测试通信</h1>
    <button id="btn">测试弹出</button>
    <button id="btnPhoto">调用相机拍照</button>
    <button id="btnSelect">选择相册</button>
    <img class="avatar" src="" alt="">
       
    <script>
        document.querySelector('#btn').addEventListener('click',()=>{
            // window.lt.showMessage('我成功了')
            const user = lt.getUser()
            lt.showMessage(JSON.stringify(user))
        })
        function changeName(name){
            document.querySelector('h1').innerText = name
        }
        document.querySelector('#btnPhoto').addEventListener('click',async ()=>{
            const url  = await lt.takePicture()
            document.querySelector('.avatar').src = url
        })
        document.querySelector('#btnSelect').addEventListener('click',async ()=>{
            const url = await lt.selectPicture()
            document.querySelector('.avatar').src = url
        })
    </script>
</body>
</html>